#pragma once
#include "Eigen/Dense"
#include "param.h"
#include "capacitor.h"
#include "inductor.h"
#include "IGBT_device_level.h"
#include "single_phase_BCTRAN_transformer.h"
#include "electric_bases.h"
using namespace Eigen;
class DAB : public electric_base
{
public:
    DAB() {}
    MatrixXd A, J, V;
    DiagonalMatrix<double, Dynamic> Yg, Yg_old;
    MatrixXd Y, Y11, Y12, Y21, Y22, Y22_inv;
    MatrixXd Geq, Jeq;
    capacitor C[2];
    IGBT_device_level IGBT[8];
    int sigs[8];
    single_phase_BCTRAN_transformer tr[1];

    param tr_params;
    double C0, C1;

    int num_node, num_br;
    const int num_ex = 3, num_in = 4;

    void setSig(int, int, int, int, int, int, int, int);
    void control();
    void begin(param &Params);
    void dsdyn_out_iteration(double delt = 0, double simulation_time = 0.0);
    void dsdyn_in_iteration(double delt = 0, double simulation_time = 0.0);
    void dsout_out_iteration();
    void dsout_in_iteration();
    void G_Ihis_mapping();
};